package edu.hgnc.controller;

import edu.hgnc.bean.User;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

@Controller
public class UserController {

	private static final Log logger = LogFactory.getLog(UserController.class);

    @RequestMapping("/userList")
    public ModelAndView handleReq(HttpServletRequest request, HttpServletResponse response) throws Exception{
		logger.warn("======================================================");
		logger.warn("hello,when you see me,that's mean you are test succeed~");
		logger.warn("======================================================");

		ArrayList<User> list = new ArrayList<>();
		User user = new User("小王", 13);
		User user1 = new User("小李", 18);
		list.add(user1);
		list.add(user);
		list.forEach(System.out::println);
		return new ModelAndView("userList","users",list);
    }

	@RequestMapping("/upload")
	public ModelAndView handleReq() throws Exception{
		logger.warn("======================================================");
		logger.warn("hello,when you see me,that's mean you are test succeed~");
		logger.warn("======================================================");

		return new ModelAndView("fileUpload");
	}
}
